package com.frank.threadPool.createThread;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author 小石潭记
 * @date 2021/4/4 13:57
 * @Description: ${todo}
 */
public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        // 1.使用继承创建线程
        ExtendsThread extendsThread = new ExtendsThread();
        extendsThread.start();

        // 2.通过实现runnable创建线程
        Thread thread = new Thread(new ImplementThread(10));
        thread.start();

        // 3.实现callable接口
        // 3.1 创建futureTask实例，创建callable实例
        FutureTask<String> task = new FutureTask<String>(new ImplementCallable());
        // 可以不用传入name
        Thread thread1 = new Thread(task, "myCallable");
        thread1.start();
        String result = task.get();
        System.out.println("callable执行返回的结果：" + result);
    }
}
